package cn.tansanqinger.ThreadPool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class NewCachedThreadPoolDemo {
    public static void main(String[] args) {
        //创建可缓存的线程池
        ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
        for (int i = 0; i <6; i++) {
            cachedThreadPool.execute(() -> {
                System.out.println(Thread.currentThread().getName());
            });
        }
        try {
            Thread.sleep(10);
        } catch (InterruptedException e) {}
        System.out.println("4秒后...");

        cachedThreadPool.shutdown();

    }
}
